// pages/nakedEyeDetails/nakeEyeDetails.js
var request = require("../../utils/request.js")
const app = getApp();
var wxCharts = require("../../js/wxcharts.js");
Page({

  /**
   * 页面的初始数据
   */
  data: {
    width: 50,
    num: 0,
    testInfo: [],
    result: "",
    chartTips: "",
    options: {}
  },
  TabClick: function (e) {
    console.log(e)
    this.setData({
      num: e.detail.num,
      current: this.data.tabTitle[e.detail.num]
    })
  },
  //色觉检查详情
  showEyeDetails: function (a) {
    var that = this;
    that.toastDialog.showDialog({ code: 'loading', message: '加载中', timeout: false }); //loading 加载框
    that.setData({ loading: true })

    let url = "xcx/testInfo";
    let data = {
      type: 4,
      tid: a
    }
    request.postData(url, data, function (res) {
      that.toastDialog.hideDialog(); //关闭loading提示框
      that.setData({ loading: false })
      if (res.code == 0) {
        that.setData({
          testInfo: res.testInfo,
          result: res.tips
        })
      } else {
        that.toastDialog.showDialog({ code: res.code, message: res.message, timeout: true });
      }

    }, function (res) {
      that.setData({ loading: false })
      that.toastDialog.showDialog({ code: res.code, message: res.message, timeout: true });
    });

  },
 //切换他人
 gotoChangePersion: function (e) {
  console.log(e);
  wx.navigateTo({
    url: '../changePersionList/changePersionList?type=4'
  })
},
  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {
    this.toastDialog = this.selectComponent("#toastDialog");//此处id和页面的 wxml中的id一致

    this.showEyeDetails(this.options.tid);
  },
  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    console.log(this.options);
    this.setData({ options: options })
    wx.showShareMenu({ menus: ['shareAppMessage', 'shareTimeline']})
  },
/**
 * 用户点击右上角分享
 */
onShareAppMessage (res) {
  return {
    title: '迪佳极视',
    path: 'pages/index/index',
    // imageUrl:'这个是显示的图片，不写就默认当前页面的截图',
    success: function (shareTickets) {
      console.info(shareTickets + '成功');
      // 转发成功
    },
    fail: function (res) {
      console.log(res + '失败');
      // 转发失败
    },
    complete:function(res){
      // 不管成功失败都会执行
    }
  }
},

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {

  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {

  }
})